package Models;

public class Addition {
	
	private String idRecipe;
	private String weight;
	private String alpha;
	
	private String hopType;
	private String additionMethod;
	
	private Ingredient theIngredient;
	
	/**
	 *  Default constructor
	 */
	public Addition() {
		
	}
	
	/**
	 * copy constructor
	 * @param old
	 */
	public Addition(Addition old) {
		this.idRecipe = old.idRecipe;
		this.weight = old.weight;
		this.alpha = old.alpha;
		this.hopType = old.hopType;
		this.additionMethod = old.additionMethod;
		this.theIngredient = new Ingredient(old.theIngredient);
	}
	
	/**
	 * @return the theIngredient
	 */
	public Ingredient getTheIngredient() {
		return theIngredient;
	}


	/**
	 * @return the idRecipe
	 */
	public String getIdRecipe() {
		return idRecipe;
	}

	/**
	 * @return the weight
	 */
	public String getWeight() {
		return weight;
	}

	/**
	 * @return the alpha
	 */
	public String getAlpha() {
		return alpha;
	}


	/**
	 * @return the hopType
	 */
	public String getHopType() {
		return hopType;
	}

	/**
	 * @return the additionMethod
	 */
	public String getAdditionMethod() {
		return additionMethod;
	}

	/**
	 * @param theIngredient the theIngredient to set
	 */
	public void setTheIngredient(Ingredient theIngredient) {
		this.theIngredient = theIngredient;
	}

	/**
	 * @param idRecipe the idRecipe to set
	 */
	public void setIdRecipe(String idRecipe) {
		this.idRecipe = idRecipe;
	}

	/**
	 * @param weight the weight to set
	 */
	public void setWeight(String weight) {
		this.weight = weight;
	}

	/**
	 * @param alpha the alpha to set
	 */
	public void setAlpha(String alpha) {
		this.alpha = alpha;
	}


	/**
	 * @param hopType the hopType to set
	 */
	public void setHopType(String hopType) {
		this.hopType = hopType;
	}

	/**
	 * @param additionMethod the additionMethod to set
	 */
	public void setAdditionMethod(String additionMethod) {
		this.additionMethod = additionMethod;
	}
	

	@Override
	public boolean equals(Object comparison) {
		boolean toReturn = true;
		Addition comp = (Addition) comparison;
		
		if(this.alpha == null) {
			if(comp.alpha != null)
				toReturn = false;
		} else if(!this.alpha.equals(comp.alpha))
			toReturn = false;
		
		if(toReturn == true) {
			if(this.hopType == null) {
				if(comp.hopType != null)
					toReturn = false;
			} else if (!this.hopType.equals(comp.hopType))
				toReturn = false;
		}
		
		if(toReturn == true) {
			if(this.additionMethod == null) {
				if(comp.additionMethod != null)
					toReturn = false;
			} else if (!this.additionMethod.equals(comp.additionMethod))
				toReturn = false;
		}
		
		if(toReturn == true && !idRecipe.equals(comp.idRecipe) && !weight.equals(comp.weight) &&
				!theIngredient.equals(comp.theIngredient))
			toReturn = false;
		
		return toReturn;
		
	}

	
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append("Addition:");
		sb.append(idRecipe);
		sb.append("||");
		sb.append(weight);
		sb.append("||");
		sb.append(hopType);
		sb.append("||");
		sb.append(alpha);
		sb.append("||");
		sb.append(additionMethod);
		sb.append("\n");
		sb.append(this.theIngredient);


		
		return sb.toString();
	}


}
